﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using GISforTT_API;

namespace SampleAgrApp
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Width = System.Windows.SystemParameters.VirtualScreenWidth;
            this.Height = System.Windows.SystemParameters.VirtualScreenHeight;
            this.Left = 0;
            this.Top = 0;
            this.ResizeMode = ResizeMode.NoResize;
            
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            GisInterfaceMgr bgm = GisInterfaceMgr.Instance;
            bgm.setMainWindow(this);
            bgm.setOrientation(Orientation.Horizontal);
            bgm.allowManipulationOfBackgroundMap(true);

            // North America
            bgm.setBackgroundMapLocation(-160.75, 10, -39.24, 60);

            // Map Layers
            List<MapLayerDef> defaultMapLayers = new List<MapLayerDef>();
            defaultMapLayers.Add(new MapLayerDef(MapLayerDef.MapLayerType.SatelliteImagery));
            defaultMapLayers.Add(new MapLayerDef(MapLayerDef.MapLayerType.OnlinePublishedMap, 
                "http://services.arcgisonline.com/ArcGIS/rest/services/Specialty/Soil_Survey_Map/MapServer"));

            bgm.setDefaultMapLayerTypes(defaultMapLayers);

            // Add GisInterfaceMgr object to the interface
            LayoutRoot.Children.Add(bgm);           
        }
    }
}
